package com.operate.util;

import com.operate.api.base.R;
import com.operate.api.base.Type;
import org.springframework.validation.BindingResult;

public class BindingResultUtil {

    public static R BindingResult(BindingResult bindingResult){
        R r=new R();
        if(bindingResult.hasErrors()) {
            r.set(Type.FORMAT_EXCEPTION).setMessage(bindingResult.getFieldErrors().get(0).getDefaultMessage());
        }
        return r;
    }
}
